<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
	<form class="form-horizontal m" id="form-lecture-add">
		<div class="form-group">
			<label class="col-sm-3 control-label">部门名称：</label>
			<div class="col-sm-8">
				<input name="deptId"  type="hidden" id="treeId" class="form-control" readonly="true"/>
				<input class="form-control" type="text" name="deptName" onclick="selectDeptTree()" readonly="true" id="treeName">
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">老师id：</label>
			<div class="col-sm-8">
				<input id="teacherId" name="teacherId" class="form-control" type="text" onclick="selectteacher()" readonly="readonly">
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">老师姓名：</label>
			<div class="col-sm-8">
				<input id="teacherName" name="teacherName" class="form-control" type="text"  readonly="readonly">
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">学生id：</label>
			<div class="col-sm-8">
				<input id="userId" name="userId" class="form-control" type="text" onclick="selectxyzlb()" readonly="readonly">
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">学生姓名：</label>
			<div class="col-sm-8">
				<input id="userName" name="userName" class="form-control" type="text" readonly="readonly">
			</div>
		</div>
		<!--<div class="form-group">
            <label class="col-sm-3 control-label">上课日期：</label>
            <div class="col-sm-8">
                <input id="classtime" name="classtime" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">上课时间：</label>
            <div class="col-sm-8">
                <input id="createTime" name="createTime" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">下课时间：</label>
            <div class="col-sm-8">
                <input id="endTime" name="endTime" class="form-control" type="text">
            </div>
        </div>-->
		<div class="form-group">
			<label class="col-sm-3 control-label">歌曲名：</label>
			<div class="col-sm-8">
				<input id="songName" name="songName" class="form-control" type="text" onclick="selectSong()" readonly="readonly">
			</div>
		</div>

		<div class="form-group">
			<label class="col-sm-3 control-label">级别：</label>
			<div class="col-sm-8">
				<input id="songLevel" name="songLevel" class="form-control" type="text"  readonly="readonly" >
			</div>
		</div>
		<!--<div class="form-group">
            <label class="col-sm-3 control-label">级别：</label>
            <div class="col-sm-8">
                <select id="songLevel" class="form-control m-b" th:with="type=${@dict.gdataetType('zl_subject_level')}">
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:-remark="${dict.remark}"  th:value="${dict.remark}"></option>
                </select>
            </div>
        </div>-->
		<div class="form-group">
			<label class="col-sm-3 control-label">课时费：</label>
			<div class="col-sm-8">
				<input id="hourSubsidy" name="hourSubsidy" class="form-control" type="text" readonly="readonly">
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">备注：</label>
			<div class="col-sm-8">
				<input id="remark" name="remark" class="form-control" type="text">
			</div>
		</div>
	</form>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript">


    /**var options_level_class = eval("[[${@dict.getTypeJson('zl_subject_level')}]]".replace(/&quot;/g, "'"));
     var options;
     var _options_html = "";
     options=options_level_class;
     for (var i = 0; i < options.length; i++) {
            var option = options[i];
            console.log(option)
            _options_html = _options_html + "<option value='" + option.dictValue + "' data-remark='"+option.remark+"'>" +  option.dictLabel + "</option>"
        }
     $("#songLevel").html(_options_html);
     $("#hourSubsidy").val($("#songLevel option:selected").attr("data-remark"))

     $("#hourSubsidy").val($("#songLevel option:selected").attr("data-remark"))
     $("#songLevel").on("change", function () {
            $("#hourSubsidy").val($("#songLevel option:selected").attr("data-remark"))
        })**/
    var prefix = ctx + "project/lecture"
    $("#form-lecture-add").validate({
        rules:{
            xxxx:{
                required:true,
            },
        }
    });

    function submitHandler() {
        if ($.validate.form()) {
            add();
        }
    }

    function add() {
        var deptId = $("input[name='deptId']").val();
        var deptName = $("input[name='deptName']").val();

        var lectureId = $("input[name='lectureId']").val();
        var teacherId = $("input[name='teacherId']").val();
        var teacherName = $("input[name='teacherName']").val();
        var userId = $("input[name='userId']").val();
        var userName = $("input[name='userName']").val();
        var songName = $("input[name='songName']").val();
        var hourSubsidy = $("input[name='hourSubsidy']").val();
        var remark = $("input[name='remark']").val();
        var songLevel = $("input[name='songLevel']").val();

        $.ajax({
            cache : true,
            type : "POST",
            url : ctx + "project/lecture/add",
            data : {
                "deptId": deptId,
                "deptName": deptName,

                "lectureId": lectureId,
                "teacherId": teacherId,
                "teacherName": teacherName,
                "userId": userId,
                "userName": userName,
                "songName": songName,
                "hourSubsidy": hourSubsidy,
                "remark": remark,
                "songLevel": songLevel,

            },
            async : false,
            error : function(request) {
                $.modal.alertError("系统错误");
            },
            success : function(data) {
                $.operate.saveSuccess(data);
            }
        });
    }

    /*用户管理-新增-选择部门树*/
    function selectDeptTree() {
        var treeId = $("#treeId").val();
        var deptId = $.common.isEmpty(treeId) ? "100" : $("#treeId").val();
        var url = ctx + "system/dept/selectDeptTree/" + deptId;
        var options = {
            title: '选择部门',
            width: "380",
            url: ctx + "system/dept/selectDeptTree/" + deptId,
            callBack: doSubmit
        };
        $.modal.openOptions(options);
    }

    function doSubmit(index, layero){
        var tree = layero.find("iframe")[0].contentWindow.$._tree;
        if ($.tree.notAllowParents(tree)) {
            var body = layer.getChildFrame('body', index);
            $("#treeId").val(body.find('#treeId').val());
            $("#treeName").val(body.find('#treeName').val());
            layer.close(index);
        }
    }
    //选择歌曲
    function selectSong() {
        var options = {
            title: '选择歌曲',
            width: "600",
            url: ctx + "project/song/data",
            callBack: selectSongCallBack
        };
        $.modal.openOptions(options);
    }
    function selectSongCallBack(index, layero) {
        var body = layer.getChildFrame('body', index)
        $("#songName").val(body.find('.selected td:nth-child(3)').text());
        $("#songLevel").val(body.find('.selected td:nth-child(5)').text());
        $("#hourSubsidy").val(body.find('.selected td:nth-child(6)').text());
        layer.close(index)
    }
    //选择学员
    function selectxyzlb() {
        var options = {
            title: '选择歌曲',
            width: "600",
            url: ctx + "project/xyzlb/data",
            callBack: selectSongCallBack1
        };
        $.modal.openOptions(options);
    }
    function selectSongCallBack1(index, layero) {
        var body = layer.getChildFrame('body', index)
        $("#userId").val(body.find('.selected td:nth-child(2)').text());
        $("#userName").val(body.find('.selected td:nth-child(5)').text());
        layer.close(index)
    }
    //选择教师
    function selectteacher() {
        var options = {
            title: '选择教师',
            width: "600",
            url: ctx + "project/teacher/data",
            callBack: selectSongCallBack2
        };
        $.modal.openOptions(options);
    }
    function selectSongCallBack2(index, layero) {
        var body = layer.getChildFrame('body', index)
        $("#teacherId").val(body.find('.selected td:nth-child(2)').text());
        $("#teacherName").val(body.find('.selected td:nth-child(4)').text());
        layer.close(index)
    }
</script>
</body>
</html>
